package com.da.springtest.order.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author chenlida
 * @date 2020/5/27 10:29
 * @description
 */
@Component
@Aspect
@Order(2)
public class Aop2 {
    @Pointcut("execution(public * com.da.springtest.order.method..*.*(..))")
    public void pointCutMethod() {}

    ////声明前置通知
    //@Before("pointCutMethod()")
    //public void doBefore(JoinPoint point) {
    //    System.out.println("AopOrder2:doBefore");
    //    return;
    //}
    //
    ////声明后置通知
    //@AfterReturning(pointcut = "pointCutMethod()", returning = "returnValue")
    //public void doAfterReturning(JoinPoint point, Object returnValue) {
    //    System.out.println("AopOrder2:doAfterReturning");
    //}
    //
    ////声明例外通知
    //@AfterThrowing(pointcut = "pointCutMethod()", throwing = "e")
    //public void doAfterThrowing(Exception e) {
    //    System.out.println("AopOrder2:doAfterThrowing");
    //}
    //
    ////声明最终通知
    //@After("pointCutMethod()")
    //public void doAfter() {
    //    System.out.println("AopOrder2:doAfter");
    //}

    //声明环绕通知  
    @Around("pointCutMethod()")
    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("AopOrder2:doAround-1");
        Object obj = pjp.proceed();
        System.out.println("AopOrder2:doAround-2");
        return obj;
    }
}
